<template>
	<view>
		<dsl-navbar title="源工智推" isBack bgTopImg="white"></dsl-navbar>
		<view style="color: #AAAAAA;" class="align-center padding justify-between bg-white animation-fade">
			<view class="sarech rowsc align-center">
				<image src="/static/icon/icon_sysous.png" mode="widthFix" style="width: 30rpx;" class="margin-right-xs">
				</image>
				<input type="text" value="" placeholder="请输入" v-model="title" />
			</view>

			<view class="align-center  text-gray">
				<image src="/static/user/modules/imgrili.png" mode="widthFix" style="width: 28rpx;" class="margin-left"
					:class="{'animation-scale-up':isTimeOrder}" @click="isTimeOrder = !isTimeOrder"></image>
			</view>
		</view>
		<view style="z-index: 999;position: relative;" class="animation-slide-top" v-if="isTimeOrder">
			<view class="bg-white">
				<view class="flex align-center rowsa">
					<view class="screening_classify " :class="{'animation-scale-up':t}" @click="t=true">
						<picker mode="date" :value="date1" start="1900-09-01" end="2090-09-01" @change="DateChange">
							<view class="picker">
								{{date1 ||'请选择开始时间'}}
							</view>
						</picker>
					</view>
					<view>-</view>
					<view class="screening_classify " :class="{'animation-scale-up':!t}" @click="t=false">
						<picker mode="date" :value="date2" start="1015-09-01" end="2090-09-01" @change="DateChange2">
							<view class="picker">
								{{date2 || '请选择结束时间'}}
							</view>
						</picker>
					</view>
				</view>
				<view class=" solid-top rowsa text-center ">
					<view class="solid-right padding" style="width: 50%;" @click="isTimeOrder = false">取消</view>
					<view class="text-red padding" style="width: 50%;" @click="submitSeach()">
						<view hover-class="animation-scale-up">确定</view>
					</view>
				</view>
			</view>
		</view>
		<view class="padding bg-white margin radius" v-for="(item,index) in list" :key="index"
			@click="noticeDetail(item)" style="position: relative;">
			<view>
				<view class="text-bold">
					<image src="/static/icon/icon_agm.png" mode=""
						style="width: 40rpx;height: 40rpx;margin-bottom: -10rpx;" class="margin-right-xs"></image>
					{{item.title}}
				</view>
				<view v-if="item.is_watch ==0"
					style="background-color: red;height: 20rpx;width: 20rpx; position: absolute; right: 30rpx;top: 10rpx;z-index: 999;"
					class="round"></view>
			</view>
			<view class="text-sm margin-top-sm">{{item.createtime }}</view>
		</view>
	</view>
</template>

<script>
	import {
		getnotice
	} from '@/common/path.js'
	export default {
		data() {
			return {
				list: [], //公告
				time: '',
				title: '',
				isTimeOrder: false,
				date1: '',
				date2: ''
			}
		},
		//生命周期函数
		onReady() {},
		onLoad() {},
		watch: {
			title() {
				this.getnotice()
			},
			date2() {
				this.getnotice()
			}
		},
		onShow() {
			this.getnotice() //公告
		},
		filters: {
			formatDate(data) { //时间戳的过滤
				var date = new Date(data * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var Y = date.getFullYear() + '-';
				var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
				var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
				var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
				var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
				return Y + M + D + h + m + s;
			},
		},
		methods: {
			//确认查询
			submitSeach(){
				this.getnotice()
				this.isTimeOrder = false
			},

			DateChange(e) {
				// console.log(e.detail.value);
				this.date1 = e.detail.value
				this.getenterprise()
			},
			DateChange2(e) {
				this.date2 = e.detail.value
				this.getenterprise()
			},


			//公告
			getnotice() {
				
				let data = {
					time:  this.date1? this.date1+ ',' + this.date2:'',
					title: this.title,
				}
				this.Http.POST(getnotice, data).then(res => {
					if (res.code == 1) {
						console.log('[公告]', res);
						this.list = res.data
					}else{
						this.list = []
					}
				})
			},
			//公告详情
			noticeDetail(item) {
				this.Http.POST(getnotice, {
					id: item.id
				})
				getApp().globalData.notice = item
				uni.navigateTo({
					url: 'noticeDetail'
				})
			}
		},
		computed: {},
		components: {},
	}
</script>

<style>
	page {
		background-color: #f7f7f7;
	}

	.screening_classify {
		height: 50rpx;
		background: #999999;
		opacity: 1;
		text-align: center;
		line-height: 50rpx;
		border-radius: 99rpx;
		color: white;
		font-size: 24rpx;
		padding-left: 20rpx;
		padding-right: 20rpx;
		margin: 10rpx;
	}
</style>
